<%--
  Created by IntelliJ IDEA.
  User: focus
  Date: 2018/1/5
  Time: 20:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<div class="aw-top-menu-wrap">
    <div class="container">
        <!-- logo -->
        <div class="aw-logo hidden-xs">
            <a href="index"></a>
        </div>
        <!-- end logo -->
        <!-- 搜索框 -->
        <div class="aw-search-box  hidden-xs hidden-sm">
            <form class="navbar-search" action="http://wenda.wecenter.com/search/" id="global_search_form" method="post">
                <input class="form-control search-query" type="text" placeholder="搜索问题、话题或人" autocomplete="off" name="q" id="aw-search-query" />
                <span title="搜索" id="global_search_btns" onClick="$('#global_search_form').submit();"><i class="icon icon-search"></i></span>
                <div class="aw-dropdown">
                    <div class="mod-body">
                        <p class="title">输入关键字进行搜索</p>
                        <ul class="aw-dropdown-list collapse"></ul>
                        <p class="search"><span>搜索:</span><a onClick="$('#global_search_form').submit();"></a></p>
                    </div>
                    <div class="mod-footer">
                        <a href="javascript:" onClick="$('#header_publish').click();" class="pull-right btn btn-mini btn-success publish">发起问题</a>
                    </div>
                </div>
            </form>
        </div>
        <!-- end 搜索框 -->
        <!-- 导航 -->
        <div class="aw-top-nav navbar">
            <div class="navbar-header">
                <button  class="navbar-toggle pull-left">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>
            <nav role="navigation" class="collapse navbar-collapse bs-navbar-collapse">
                <ul class="nav navbar-nav">
                    <c:if test="${sessionScope._current_user ne null}">
                    <li><a href="home/" id="home"><i class="icon icon-home"></i> 动态</a></li>
                    </c:if>
                    <li><a href="index/" id="index"><i class="icon icon-list"></i> 发现</a></li>
                    <li><a href="topic/" id="topic"><i class="icon icon-topic"></i> 话题</a></li>
                    <li><a href="article/page-1" id="article"><i class="icon icon-reader"></i> 文章</a></li>
                </ul>
            </nav>
        </div>
        <!-- end 导航 -->
        <div class="aw-user-nav">
            <!-- 登陆&注册栏 -->
            <c:if test="${sessionScope._current_user eq null}">
            <a class="login btn btn-normal btn-primary" href="user/login">登录</a>
            <a class="register btn btn-normal btn-success" href="user/register/">注册</a>
            </c:if>
            <!-- end 登陆&注册栏 -->
            <!-- 用户栏 -->
            <c:if test="${sessionScope._current_user ne null}">
            <c:set var="user" value="${sessionScope._current_user}" scope="page"/>
            <a href="http://wenda.wecenter.com/people/FOCUS" class="aw-user-nav-dropdown">
                <img alt="${user.username}" src="${user.headPortrait}" />
            </a>
            <div class="aw-dropdown dropdown-list pull-right">
                <ul class="aw-dropdown-list">
                    <li class="hidden-xs"><a href="http://wenda.wecenter.com/account/setting/profile/"><i class="icon icon-setting"></i> 设置</a></li>
                    <li><a href="user/logout"><i class="icon icon-logout"></i> 退出</a></li>
                </ul>
            </div>
            </c:if>
            <!-- end 用户栏 -->
        </div>
        <c:if test="${sessionScope._current_user ne null}">
        <!-- 发起 -->
        <div class="aw-publish-btn">
            <a id="header_publish" class="btn-primary" href="javascript:" onclick="AWS.dialog('publish', {'category_enable':'1', 'category_id':'0', 'topic_title':''}); return false;"><i class="icon icon-ask"></i>发起</a>
            <div class="dropdown-list pull-right">
                <ul>
                    <li>
                        <form method="post" action="question/publish/">
                            <a onclick="$(this).parents('form').submit();">问题</a>
                        </form>
                    </li>
                    <li>
                        <form method="post" action="article/publish">
                            <a onclick="$(this).parents('form').submit();">文章</a>
                        </form>
                    </li>
                </ul>
            </div>
        </div>
        <!-- end 发起 -->
        </c:if>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        var uri = window.location.pathname;//   /index/
        if (uri.length <= 1) {
            return;
        }
        uri = uri.substring(1);
        uri = uri.substring(0, uri.indexOf("/"));
        switch (uri) {
            case "home":
                $("#home").addClass("active");
                break;
            case "topic":
                $("#topic").addClass("active");
                break;
            case "article":
                $("#article").addClass("active");
                break;
            default:
                $("#index").addClass("active");
        }
    });
</script>